
{mfdeclre.i "new global"} 
global_userid = "MFG".
global_user_lang_dir = "ch/".
global_user_site = '210,220,230,240,250,260,410,500,510'.

{gldydef.i new}
{gldynrm.i new}

{ppbdov.i}

DEFINE VARIABLE part     LIKE pt_part     NO-UNDO.
DEFINE VARIABLE site     LIKE si_site     NO-UNDO.
DEFINE VARIABLE sim      LIKE sc_sim      NO-UNDO.
DEFINE VARIABLE element  LIKE spt_element NO-UNDO.
DEFINE VARIABLE cst_old  LIKE sct_cst_tot NO-UNDO.
DEFINE VARIABLE cst_new  LIKE sct_cst_tot NO-UNDO.
DEFINE VARIABLE category LIKE sc_category NO-UNDO.
DEFINE VARIABLE add_replace LIKE  mfc_logical NO-UNDO.
DEFINE VARIABLE rndmthd  LIKE gl_rnd_mthd NO-UNDO.
site = "510".
sim = "Standard".
element = "Burden".
part = "181-0168053".
add_replace = YES.

FOR FIRST sc_mstr fields (sc_category sc_element sc_sim) WHERE sc_sim  = sim and sc_element = element NO-LOCK:
END.

FOR FIRST icc_ctrl fields(icc_cogs icc_gl_sum icc_gl_tran icc_mirror icc_jrnl icc_cur_set icc_gl_set) NO-LOCK:
END.

FOR FIRST gl_ctrl FIELDS(gl_rnd_mthd) NO-LOCK:
    rndmthd = gl_rnd_mthd.
END.


FOR EACH pt_mstr FIELDS (pt_part pt_desc1 pt_part_type pt_pm_code pt_prod_line pt_site pt_um) WHERE pt_part BEGINS part NO-LOCK:

    FIND FIRST sct_det WHERE sct_part = part AND sct_site = site AND sct_sim = sim EXCLUSIVE-LOCK NO-ERROR.
    IF AVAILABLE sct_det THEN DO:
       ASSIGN cst_old = sct_cst_tot.
       ASSIGN cst_new = sct_lbr_tl * 0.035 + sct_mtl_ll * 0.04095.
       run update_cost (input element, input category, input cst_new, input add_replace, buffer sct_det).
       
       run create_inv_gl_trans (input cst_old, input site, input rndmthd, output trmsg, buffer sct_det,buffer icc_ctrl,buffer pt_mstr).
       DISP trmsg pt_part sct_site sct_sim cst_old sct_cst_tot.
    END.

END.
